<?php
namespace cms\modules\v1\controllers;

use cms\modules\common\controllers\DefaultController;
use cms\modules\v1\models\feedback\FeedbackInfo;
use cms\modules\v1\models\feedback\FeedbackType;
use Yii;
/**
 * Default controller for the `v1` module
 */
class FeedbackController extends DefaultController
{
    
    public $modelClass = '';

    //============================ 反馈分类 ============================
    /**
     * 获取分类
     * @return array|mixed|\yii\db\ActiveRecord[]
     */
    public function actionType() {
        if (\Yii::$app->request->isGet) {
            return (new FeedbackType())->getList();
        }
    }
    
    public function actionTypeInfo($id = 0) {
        if (\Yii::$app->request->isPost) {
            return (new FeedbackType())->saveInfo();
        }
        if (\Yii::$app->request->isGet) {
            return (new FeedbackType())->getInfo($id);
        }
    }

    public function actionTypeField($id = 0) {
        if (\Yii::$app->request->isPost) {
            return (new FeedbackType())->setField();
        }
    }

    //============================ 反馈信息 ============================
    public function actionList($page = 1, $size = 50) {
        #获取帮助信息
        if (\Yii::$app->request->isGet) {
            return (new FeedbackInfo())->getListData($page, $size);
        }
    }

    public function actionInfo($id = 0) {
        if (\Yii::$app->request->isGet) {
            return (new FeedbackInfo())->getInfo($id);
        }
        if (\Yii::$app->request->isPost) {
            return (new FeedbackInfo())->saveInfo();
        }
    }
    
    // 回复信息
    public function actionReply() {
        if (\Yii::$app->request->isPost) {
            return (new FeedbackInfo())->multipleReply();
        }
    }
    
    // 删除反馈信息
    public function actionDel() {
        if (\Yii::$app->request->isPost) {
            return (new FeedbackInfo())->multipleDelete();
        }
    }

    //待审核审核
    public function actionAudit() {
        if (Yii::$app->request->isGet) {
            return (new FeedbackInfo())->queryAudit();
        }
    }

}
